#include <string.h>
#include <stdio.h>
#include <stdlib.h>


#include "content.h"
#include "get_index.h"

char *
get_content_type(char *url)
{
  printf("url = %s\n",url);

  char *extension = strrchr(url,'.');

  printf("extension = %s\n",extension);

  if (extension == NULL )
    {
      if (est_dossier(url))
	return content_html;
      else 
	return NULL;
    }


  if (!strcmp(extension,".html") || !strcmp(extension,".htm")|| !strcmp(extension,".cpp"))
    return content_html;
  
  if (!strncmp(extension,".jp",2))
    return content_jpeg;

  if (!strncmp(extension,".mp",2))
    return content_mpeg;

  if (!strcmp(extension,".png"))
    return content_png;

  if (!strcmp(extension,".gif"))
    return content_gif;

  if (!strcmp(extension,".txt")) 
    return content_plain;

  if (!strcmp(extension,".c") || !strcmp(extension,".h"))
    return content_rich;

  if (!strcmp(extension,".pdf"))
    return content_pdf;
  
  if (!strcmp(extension,".ps") || !strcmp(extension,".ai") || !strcmp(extension,".eps"))
    return content_ps;
  
  return content_html;//par default

}
